package com.it.test;

public class test7 {
    public static void main(String[] args) {
        //需求：
        //把整数上的每一位都添加到数组当中
        //反向推导

        //1.计算数组的长度
        int number = 12345;
        int temp = number;
        int count = 0;
        while(number != 0){
            number = number/10;
            count++;
        }
        //System.out.println(count);
        //2.定义数组
        //动态初始化
        int[] arr = new int[count];
        int index = arr.length - 1;
        while(temp != 0){
            //获取temp里面的每一位数
            int ge = temp%10;
            //再去掉temp里面的每一位数
            temp = temp/10;
            //把当前获取的数存入
            arr[index] = ge;
            index--;//arr[count-index]=ge;
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }
}
